function GameObj(option) {
  this.left = option.x || 0;
  this.top = option.y || 0;
  this.height = option.h || 0;
  this.width = option.w || 0;
  this.moveX = option.Mx || 0;
  this.moveY = option.My || 0;
  this.Cx = option.Cx || 0;
  this.Cy = option.Cy || 0;
  this.img = new Image();
  this.appNum = 0;
  this.img.src = option.url;
  this.rotate = option.rotate || 0;
  this.speed = option.speed || 1;
  this.crashX;
  this.crashY;

}
GameObj.prototype = {
  draw: function() {
    ctx.save();
    ctx.translate(Cannon.x, Cannon.y);
    ctx.rotate(this.rotate);
    // console.log(this.left);
    // alert(this.crashX+"+"+this.crashY);
    ctx.drawImage(this.img, 0, 0, this.width, this.height, this.Cx - 1, this.Cy - 10, this.width, this.height);
    ctx.restore();
  },
  move: function() {
    // var speedX = Math.sin(180 / Math.PI * this.rotate) * this.speed;
    // var speedY = Math.cos(180 / Math.PI * this.rotate) * this.speed;
    this.Cx += this.speed;
    this.crashX = Cannon.x + Math.cos(this.rotate) * this.Cx;
    this.crashY = Cannon.y + Math.sin(this.rotate) * this.Cx;
    this.Cy = -5;
  }
}

function createBullet(bulletX, bulletY) {
  var bullet = new GameObj({
    x: bulletX,
    y: bulletY,
    w: 60,
    h: 40,
    left: 0,
    top: 0,
    rotate: 0,
    speed: 10,
    url: "img/bullet0.png"
  });
  return bullet;
}
